{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ffbfe34a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 模拟暗霞世界的函数\n",
    "from real import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e5591b47",
   "metadata": {},
   "outputs": [],
   "source": [
    "from prettytable import PrettyTable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "42ba3900",
   "metadata": {},
   "outputs": [],
   "source": [
    "def red(text):\n",
    "    return \"\\033[31m\" + str(text) + \"\\033[0m\""
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "07a0bba2",
   "metadata": {},
   "source": [
    "## 2 经验的预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a2df7510",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 「经验预测」\n",
    "# 输入: 暗霞（用x表示），手心数值（用num表示）\n",
    "# 输出: 上升/下降n点数值\n",
    "def experience_prediction(x, num):\n",
    "    if x == '①':\n",
    "        num += 14\n",
    "    elif x == '②':\n",
    "        num += 14\n",
    "    elif x == '③':\n",
    "        num += 6\n",
    "    elif x == '④':\n",
    "        num -= 21\n",
    "    else:\n",
    "        print(\"未知，无法预测\")\n",
    "    return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b151d76c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+----------+--------------------+----------------+\n",
      "| 暗霞 | 手心数字 | 预测数值(经验预测) | \u001b[31m触碰暗霞后数值\u001b[0m |\n",
      "+------+----------+--------------------+----------------+\n",
      "|  ①   |    3     |         17         |       \u001b[31m17\u001b[0m       |\n",
      "|  ②   |    15    |         29         |       \u001b[31m29\u001b[0m       |\n",
      "|  ③   |    22    |         28         |       \u001b[31m28\u001b[0m       |\n",
      "|  ④   |    28    |         7          |       \u001b[31m7\u001b[0m        |\n",
      "+------+----------+--------------------+----------------+\n"
     ]
    }
   ],
   "source": [
    "# 打印出「经验预测」与「实际情况」\n",
    "table = PrettyTable()\n",
    "table.field_names = ['暗霞','手心数字', '预测数值(经验预测)', red('触碰暗霞后数值')]\n",
    "\n",
    "for x, num in zip(['①', '②', '③', '④'], [3, 15, 22, 28]):\n",
    "    expect_num = experience_prediction(x, num) # 经验预测的值\n",
    "    real_change = touch_x(x, num) # 实际触碰后的值\n",
    "    \n",
    "    table.add_row([x, num, expect_num, red(real_change)])\n",
    "\n",
    "print(table)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "a8e06787",
   "metadata": {},
   "source": [
    "### 3.2.2 表征"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "f3cf1139",
   "metadata": {},
   "source": [
    "随后，你又用「弦的个数」来「代表（Represent）」现实中的「暗霞」，于是之前你所记忆过的那些纹路复杂、无法用语言描述的「暗霞」就都变成了可被描述的「弦数」：\n",
    "+ 第一次触碰的暗霞：08 个弦\n",
    "+ 第二次触碰的暗霞：08 个弦\n",
    "+ 第三次触碰的暗霞：04 个弦\n",
    "+ 第四次触碰的暗霞：09 个弦"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9e1b9799",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 不知道怎么模拟，只好用这种简单粗暴的方式；\n",
    "# 这个模拟的缺陷就是仅仅模拟了世界模型故事里的已见情况，不能模拟出里面的未见情况\n",
    "# 表征V1\n",
    "chord_dict = {\n",
    "    '①': 8,\n",
    "    '②': 8,\n",
    "    '③': 4,\n",
    "    '④': 9,\n",
    "    '⑤': 10,\n",
    "    '⑥': 6,\n",
    "    '⑦': 6,\n",
    "    '⑧': 8,\n",
    "    '⑨': 7\n",
    "}\n",
    "# 输入：暗霞\n",
    "# 输出：弦（暗霞的表征）\n",
    "def representation_v1(x):\n",
    "    return chord_dict[x] if x in chord_dict else None"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "8b81f52c",
   "metadata": {},
   "source": [
    "### 3.3.1 升降模型V1"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "e1f06e10",
   "metadata": {},
   "source": [
    "你察觉到，自己前三次触碰的暗霞的弦数分别为 8，8，4，都可以被 2 整除，触碰它们后，手心数值都提升了。只有第四次触碰的暗霞的弦数不能被 2 整除，也唯独在你触碰这颗暗霞后，手心数值下降了。\n",
    "+ 第一次触碰的暗霞：08 个弦 -> 可以被 2 整除 -> 数值提升了\n",
    "+ 第二次触碰的暗霞：08 个弦 -> 可以被 2 整除 -> 数值提升了\n",
    "+ 第三次触碰的暗霞：04 个弦 -> 可以被 2 整除 -> 数值提升了\n",
    "+ 第四次触碰的暗霞：09 个弦 -> 不能被 2 整除 -> 数值降低了\n",
    "\n",
    "你找到了「弦数」和「升降情况」这两个信息之间，在上述四个经验中，所存在的一个「规律（共有的关系）」，即「能被 2 整除的弦数，数值提升；不能被 2 整除的弦数，数值下降」。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b34cad8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 升降模型V1\n",
    "# 输入：弦数\n",
    "# 输出：数值上升或下降\n",
    "def is_increase_model_v1(chord_num):\n",
    "    if(chord_num % 2 == 0):\n",
    "        return True\n",
    "    else:\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a9941d4c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 打印出「升降模型V1」与「实际情况」\n",
    "def print_increase_v1(input_list):\n",
    "    table = PrettyTable()    \n",
    "    table.field_names = ['暗霞', '弦数(表征)', '预测升降(升降模型V1)', red('实际升降')] \n",
    "    \n",
    "    for x in input_list:\n",
    "        chord_num = representation_v1(x) # 暗霞的表征：弦数\n",
    "        increase_or_decrease = '上升' if is_increase_model_v1(chord_num) else '下降' # 「升降模型V1」预测上升或下降\n",
    "        real_change = '上升' if is_increase(x) else '下降' # 实际升降情况\n",
    "        \n",
    "        table.add_row([x, chord_num, increase_or_decrease, red(real_change)])\n",
    "\n",
    "    print(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7711d376",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+----------------------+----------+\n",
      "| 暗霞 | 弦数(表征) | 预测升降(升降模型V1) | \u001b[31m实际升降\u001b[0m |\n",
      "+------+------------+----------------------+----------+\n",
      "|  ①   |     8      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ②   |     8      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ③   |     4      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ④   |     9      |         下降         |   \u001b[31m下降\u001b[0m   |\n",
      "+------+------------+----------------------+----------+\n"
     ]
    }
   ],
   "source": [
    "known_x = ['①', '②', '③', '④']\n",
    "print_increase_v1(known_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d1f67155",
   "metadata": {},
   "source": [
    "### 3.4.2 数值模型V1"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "b4e4e067",
   "metadata": {},
   "source": [
    "在建构这个模型时，你所关注的是手心数值会「提升还是下降」，属于一个“定性”的问题。我们姑且把这个模型称为「升降模型」。除此之外，你还想知道「数值会变化多少」这种“定量”的问题，于是你再次进行了归纳，又在「暗霞」和「数值变化量」之间，建构了一个模型，即「弦数*2 - 2 = 数值变化量」，我们且把这个模型叫做「数值模型」。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "269c6860",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数值模型V1\n",
    "# 输入：弦数\n",
    "# 输出：手心数字变化量\n",
    "def numeric_model_v1(chord_num):\n",
    "    numeric_change = chord_num * 2 - 2\n",
    "    return numeric_change"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c977fcdd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 打印「数值模型V1」与「实际情况」\n",
    "def print_numeric_model_v1(input_list):\n",
    "    table = PrettyTable()\n",
    "    table.field_names = ['暗霞', '弦数(表征)', '预测变化值(数值模型V1)', red('实际变化值')]\n",
    "\n",
    "    for x in input_list:\n",
    "        chord_num = representation_v1(x) # 暗霞的表征：弦数\n",
    "        numeric_change = numeric_model_v1(chord_num) # 「数值模型V1」预测的变化值\n",
    "        change = red(num_change(x)) # 实际变化值\n",
    "        \n",
    "        table.add_row([x, chord_num, numeric_change, change])\n",
    "\n",
    "    print(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2b0ce766",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+------------------------+------------+\n",
      "| 暗霞 | 弦数(表征) | 预测变化值(数值模型V1) | \u001b[31m实际变化值\u001b[0m |\n",
      "+------+------------+------------------------+------------+\n",
      "|  ①   |     8      |           14           |     \u001b[31m14\u001b[0m     |\n",
      "|  ②   |     8      |           14           |     \u001b[31m14\u001b[0m     |\n",
      "|  ③   |     4      |           6            |     \u001b[31m6\u001b[0m      |\n",
      "|  ④   |     9      |           16           |     \u001b[31m21\u001b[0m     |\n",
      "+------+------------+------------------------+------------+\n"
     ]
    }
   ],
   "source": [
    "known_x = ['①', '②', '③', '④']\n",
    "print_numeric_model_v1(known_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "11710e8c",
   "metadata": {},
   "source": [
    "不过，在你审视自己所建构的「数值模型」时却发现，该模型只能同时符合前三个经验，不符合第四个经验，意味着，刚才你归纳出的「弦数*2 - 2 = 数值变化量」并不是全部四个经验所共有的规律，压缩失败了。\n",
    "+ 第一次触碰的暗霞：08 个弦 -> 数值模型 -> 数值变化了 14（真实情况：14）\n",
    "+ 第二次触碰的暗霞：08 个弦 -> 数值模型 -> 数值变化了 14（真实情况：14）\n",
    "+ 第三次触碰的暗霞：04 个弦 -> 数值模型 -> 数值变化了 06（真实情况：06）\n",
    "+ 第四次触碰的暗霞：09 个弦 -> 数值模型 -> 数值变化了 16（真实情况：21）"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "7d307d3e",
   "metadata": {},
   "source": [
    "### 3.4.4 多维表征"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "8682279f",
   "metadata": {},
   "source": [
    "于是你再次进行了抽象和归纳，这一次，你从众多暗霞中，又多抽象出来了一个概念「环」，用「弦数&环数」来共同代表「暗霞」，意味着这一次你给「暗霞」所选择的「表征」是「弦数&环数」这两个维度所形成的整体，也可称为「多维表征」。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "fa7d3a5c",
   "metadata": {},
   "outputs": [],
   "source": [
    "chord_loop_dict = { \n",
    "    '①': (8, 8), \n",
    "    '②': (8, 8), \n",
    "    '③': (4, 4),\n",
    "    '④': (9, 14), \n",
    "    '⑤': (10, 10), \n",
    "    '⑥': (6, 5),\n",
    "    '⑦': (6, 8),\n",
    "    '⑧': (8, 6),\n",
    "    '⑨': (7, 10)\n",
    "}\n",
    "\n",
    "# 同样不知道怎么模拟\n",
    "# 输入：暗霞\n",
    "# 输出：弦，环（暗霞的表征）\n",
    "def representation_v2(x):\n",
    "    return chord_loop_dict[x] if x in chord_loop_dict else None"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "c3a49a85",
   "metadata": {},
   "source": [
    "### 3.4.4 数值模型V2"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "e753df2c",
   "metadata": {},
   "source": [
    "随后，你从四个经验中，找到了「弦数&环数」和「数值变化量」之间的一个「共有关系（模式）」，即「弦数 + 环数 - 2 = 数值变化量」，并用这个「关系」建构了第二代数值模型，命名为「数值模型V2」，该模型就成功地克服了第一代「数值模型V1」归纳不足的问题，压缩了所有旧经验。\n",
    "+ 第一次触碰的暗霞：08 个弦，08个环 -> 数值模型V2 -> 数值变化了 14（真实情况：14）\n",
    "+ 第二次触碰的暗霞：08 个弦，08个环 -> 数值模型V2 -> 数值变化了 14（真实情况：14）\n",
    "+ 第三次触碰的暗霞：04 个弦，04个环 -> 数值模型V2 -> 数值变化了 06（真实情况：06）\n",
    "+ 第四次触碰的暗霞：09 个弦，14个环 -> 数值模型V2 -> 数值变化了 21（真实情况：21）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "115dda4d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数值模型V2\n",
    "# 输入：弦数，环数\n",
    "# 输出：手心数字变化量\n",
    "def numeric_model_v2(chord_num, loop_num):\n",
    "    numeric_change = chord_num + loop_num - 2\n",
    "    return numeric_change"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "329562ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 打印「数值模型V2」与「实际情况」\n",
    "def print_numeric_model_v2(input_list):\n",
    "    table = PrettyTable()\n",
    "    table.field_names = ['暗霞', '弦数(表征)', '环数(表征)','预测变化值(数值模型V2)', red('实际变化值')]\n",
    "\n",
    "    for x in input_list:\n",
    "        chord_num, loop_num = representation_v2(x) # 弦数，环数\n",
    "        numeric_change = numeric_model_v2(chord_num, loop_num)  # 「数值模型V2」预测的变化值\n",
    "        change = red(num_change(x)) #  实际变化值\n",
    "        \n",
    "        table.add_row([x, chord_num, loop_num, numeric_change, change])\n",
    "\n",
    "    print(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9d416080",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+------------+------------------------+------------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测变化值(数值模型V2) | \u001b[31m实际变化值\u001b[0m |\n",
      "+------+------------+------------+------------------------+------------+\n",
      "|  ①   |     8      |     8      |           14           |     \u001b[31m14\u001b[0m     |\n",
      "|  ②   |     8      |     8      |           14           |     \u001b[31m14\u001b[0m     |\n",
      "|  ③   |     4      |     4      |           6            |     \u001b[31m6\u001b[0m      |\n",
      "|  ④   |     9      |     14     |           21           |     \u001b[31m21\u001b[0m     |\n",
      "+------+------------+------------+------------------------+------------+\n"
     ]
    }
   ],
   "source": [
    "known_x = ['①', '②', '③', '④']\n",
    "print_numeric_model_v2(known_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "fef1734c",
   "metadata": {},
   "source": [
    "## 3.5 泛化能力"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "afe10903",
   "metadata": {},
   "source": [
    "就在你为自己的成功高兴时，饥饿感的再次增加，将你从思考中拉回到了现实，不用看也知道手心的数字仅剩 1 了。你仔细观察着面前的两颗暗霞，\n",
    "\n",
    "左边的是 10 弦 10 环，右边的是 11 弦 8 环。利用「升降模型」，你预测左边的暗霞会“提升数值”，右边的会“降低数值”；\n",
    "\n",
    "再利用「数值模型V2」，你预测左边的暗霞会导致“18 点的数值变化”，右边的会导致“17 点的数值变化”。\n",
    "\n",
    "你握了一下右拳，随后紧闭双眼，伸向了左侧。待你睁开眼时，掌心的数字已经变成了 19。真的如两个模型所预测那样，提升了，而且是 18 点。你成功地预测了一次从未见过的新情况。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "8ae0ccd9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+----------------------+----------+\n",
      "| 暗霞 | 弦数(表征) | 预测升降(升降模型V1) | \u001b[31m实际升降\u001b[0m |\n",
      "+------+------------+----------------------+----------+\n",
      "|  ⑤   |     10     |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "+------+------------+----------------------+----------+\n",
      "+------+------------+------------+------------------------+------------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测变化值(数值模型V2) | \u001b[31m实际变化值\u001b[0m |\n",
      "+------+------------+------------+------------------------+------------+\n",
      "|  ⑤   |     10     |     10     |           18           |     \u001b[31m18\u001b[0m     |\n",
      "+------+------------+------------+------------------------+------------+\n"
     ]
    }
   ],
   "source": [
    "unknown_x = '⑤'\n",
    "print_increase_v1(unknown_x)\n",
    "print_numeric_model_v2(unknown_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "a318002c",
   "metadata": {},
   "source": [
    "这一刻你兴奋不已，不仅因为自己活了下来，还因为你发现了暗霞背后的“客观规律”。带着激动的心情，你跑向了之前见过的另一个弦数能被 2 所整除的暗霞前，因为「升降模型」预测这颗 6 弦 5 环的暗霞也会“提升数值”，再由「数值模型V2」可预测，它将导致“9 点的数值变化”。你期待着数值将会提升 9 点，然而在你触碰后，脸上的期待立刻变成了疑惑。这一次，手心的数值没有提升，而是下降了 9 点，「升降模型」的预测失败了。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1c3df1dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+----------------------+----------+\n",
      "| 暗霞 | 弦数(表征) | 预测升降(升降模型V1) | \u001b[31m实际升降\u001b[0m |\n",
      "+------+------------+----------------------+----------+\n",
      "|  ⑥   |     6      |         上升         |   \u001b[31m下降\u001b[0m   |\n",
      "+------+------------+----------------------+----------+\n",
      "+------+------------+------------+------------------------+------------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测变化值(数值模型V2) | \u001b[31m实际变化值\u001b[0m |\n",
      "+------+------------+------------+------------------------+------------+\n",
      "|  ⑥   |     6      |     5      |           9            |     \u001b[31m9\u001b[0m      |\n",
      "+------+------------+------------+------------------------+------------+\n"
     ]
    }
   ],
   "source": [
    "unknown_x = '⑥'\n",
    "print_increase_v1(unknown_x)\n",
    "print_numeric_model_v2(unknown_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "b412555a",
   "metadata": {},
   "source": [
    "### 3.5.2 更新模型"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "318c9a82",
   "metadata": {},
   "source": [
    "不过，曾经从未见过的那两个新情况，现在已经成为了旧经验，你可以将其和之前的四个经验，共同作为抽象与归纳的新依据，来「更新」你的「升降模型」。这一次，你把「环数」的概念也加入到了「升降模型」中，共同作为暗霞的表征。你发现，只要把「弦数，能否被 2 整除」改为「弦数和环数的总和，能否被 2 整除」就可以归纳全部六个经验了，于是你建构出了「升降模型V2」，这个模型有更大概率能预测出所有未见过的新情况。\n",
    "+ 第一次触碰的暗霞：08 个弦，08个环 -> 升降模型V2 -> 数值提升了（真实情况：提升）\n",
    "+ 第二次触碰的暗霞：08 个弦，08个环 -> 升降模型V2 -> 数值提升了（真实情况：提升）\n",
    "+ 第三次触碰的暗霞：04 个弦，04个环 -> 升降模型V2 -> 数值提升了（真实情况：提升）\n",
    "+ 第四次触碰的暗霞：09 个弦，14个环 -> 升降模型V2 -> 数值下降了（真实情况：下降）\n",
    "+ 第五次触碰的暗霞：10 个弦，10个环 -> 升降模型V2 -> 数值提升了（真实情况：提升）\n",
    "+ 第六次触碰的暗霞：06 个弦，05个环 -> 升降模型V2 -> 数值下降了（真实情况：下降）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "4c497bba",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 升降模型V2\n",
    "# 输入：弦数，环数\n",
    "# 输出：数值上升或下降\n",
    "def is_increase_model_v2(chord_num, loop_num):\n",
    "    if((chord_num + loop_num) % 2 == 0):\n",
    "        return True\n",
    "    else:\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "264178e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 打印出「升降模型V2」与实际情况\n",
    "\n",
    "def print_increase_v2(input_list):\n",
    "    table = PrettyTable()\n",
    "    table.field_names = ['暗霞', '弦数(表征)', '环数(表征)', '预测升降(升降模型V2)', red('实际升降')] \n",
    "    \n",
    "    for x in input_list:\n",
    "        chord_num, loop_num = representation_v2(x)\n",
    "        ascend_or_descend = '上升' if is_increase_model_v2(chord_num, loop_num) else '下降'\n",
    "        real_change = '上升' if is_increase(x) else '下降'\n",
    "        \n",
    "        table.add_row([x, chord_num, loop_num, ascend_or_descend, red(real_change)])\n",
    "\n",
    "    print(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "16135e37",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+------------+----------------------+----------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测升降(升降模型V2) | \u001b[31m实际升降\u001b[0m |\n",
      "+------+------------+------------+----------------------+----------+\n",
      "|  ①   |     8      |     8      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ②   |     8      |     8      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ③   |     4      |     4      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ④   |     9      |     14     |         下降         |   \u001b[31m下降\u001b[0m   |\n",
      "|  ⑤   |     10     |     10     |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ⑥   |     6      |     5      |         下降         |   \u001b[31m下降\u001b[0m   |\n",
      "+------+------------+------------+----------------------+----------+\n"
     ]
    }
   ],
   "source": [
    "known_x = ['①', '②', '③', '④', '⑤', '⑥']\n",
    "print_increase_v2(known_x)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "9d5c067a",
   "metadata": {},
   "source": [
    "### 3.5.2 验证"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "b543bfa0",
   "metadata": {},
   "source": [
    "但上次的预测失败让你变得警惕，这次你先用「数值模型V2」挑选了三个「数值变化量」相对较小的暗霞，来「验证」新建的「升降模型V2」对「未见新情况」的预测能力，你甚至还选了一个被「升降模型V2」预测为会“降低数值”的暗霞来验证。最终，你触碰这三颗暗霞后的结果，全部都符合「升降模型V2」的预测，让你在这个充满未知的星球上，感到了一丝确定性。\n",
    "第七次触碰的暗霞：06 个弦，08个环 -> 升降模型V2 -> 数值提升（真实情况：提升）\n",
    "第八次触碰的暗霞：08 个弦，06个环 -> 升降模型V2 -> 数值提升（真实情况：提升）\n",
    "第九次触碰的暗霞：07 个弦，10个环 -> 升降模型V2 -> 数值下降（真实情况：下降）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d9e1497a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+------+------------+------------+----------------------+----------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测升降(升降模型V2) | \u001b[31m实际升降\u001b[0m |\n",
      "+------+------------+------------+----------------------+----------+\n",
      "|  ⑦   |     6      |     8      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ⑧   |     8      |     6      |         上升         |   \u001b[31m上升\u001b[0m   |\n",
      "|  ⑨   |     7      |     10     |         下降         |   \u001b[31m下降\u001b[0m   |\n",
      "+------+------------+------------+----------------------+----------+\n",
      "+------+------------+------------+------------------------+------------+\n",
      "| 暗霞 | 弦数(表征) | 环数(表征) | 预测变化值(数值模型V2) | \u001b[31m实际变化值\u001b[0m |\n",
      "+------+------------+------------+------------------------+------------+\n",
      "|  ⑦   |     6      |     8      |           12           |     \u001b[31m12\u001b[0m     |\n",
      "|  ⑧   |     8      |     6      |           12           |     \u001b[31m12\u001b[0m     |\n",
      "|  ⑨   |     7      |     10     |           15           |     \u001b[31m15\u001b[0m     |\n",
      "+------+------------+------------+------------------------+------------+\n"
     ]
    }
   ],
   "source": [
    "# 触碰未知暗霞来验证\n",
    "unknown_x = ['⑦', '⑧', '⑨'] \n",
    "print_increase_v2(unknown_x)\n",
    "print_numeric_model_v2(unknown_x)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bot",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
